import logging

import redis


class Config(object):

    SECRET_KEY = "EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA"
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/NEWS"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    HOST = '127.0.0.1'
    PORT = 6379
    SESSION_TYPE = "redis"  # 指定 session 保存到 redis 中
    SESSION_USE_SIGNER = True  # 让 cookie 中的 session_id 被加密签名处理
    SESSION_REDIS = redis.StrictRedis(host=HOST, port=PORT)  # 使用 redis 的实例
    SESSION_REDIS.set("name", 'xiaoming')
    # session['xiaoming'] = '333'
    PERMANENT_SESSION_LIFETIME = 86400 *2 # session 的有效期，单位是秒
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    # 设置日志的记录等级
    LOG_LEVEL = logging.DEBUG


class DEVELOPMENT(Config):
    DEBUG = True


class PRODUCTION(Config):
    DEBUG = False
    LOG_LEVEL = logging.WARNING

class TESTING(Config):
    DEBUG = True
    TESTING = True

config = {
    'development': DEVELOPMENT,
    'production': PRODUCTION,
    'testing': TESTING
}